<!doctype html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:replace="common/backstageNavigator.html :: head"></div>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>教务后台管理系统</title>

    <script src="./js/vue.js"></script>

    <!-- Bootstrap core CSS -->
    <!--<link href="static/css/bootstrap.min.css" rel="stylesheet">-->
    <link rel="stylesheet" href="css/bootstrap.min.css"
          integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <!-- Custom styles for this template -->
    <link href="css/dashboard.css" rel="stylesheet">
    <link href="css/classscheduling.css" rel="stylesheet">
    <script src="js/backstage/my_axios.min.js"></script>
    <script src="js/vue.js"></script>
    <script src="js/vue-resource.min.js"></script>
    <script src="js/grade/jquery-3.3.1.min.js"></script>
</head>

<body>
<div th:replace="common/backstageNavigator.html :: banner"></div>

<div class="container-fluid" id="classscheduling">
    <div class="row">
        <div th:replace="common/backstageNavigator.html :: navi"></div>
        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <!--下面是课程表-->
            <div class="course_form">
                <fieldset><legend><h2>课程表查询</h2></legend>
                        <h5>学年：</h5><select v-model="table_year" style="height:25px;width:164px">
                            <option value="2019-2020学年">2019-2020学年</option>
                            <option value="2018-2019学年">2018-2019学年</option>
                            <option value="2017-2018学年">2017-2018学年</option>
                            <option value="2016-2017学年">2016-2017学年</option>
                            <option value="2015-2016学年">2015-2016学年</option>
                            <option value="2014-2015学年">2014-2015学年</option>
                        </select>
                        <h5>学期：</h5><select v-model="table_semester" style="height:25px;width:164px">
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                        </select>
                        <h5>专业：</h5><input v-model="table_major" name="专业" type="text" />
                        <h5>年级：</h5><select id = 'table_grade' v-model="table_grade" style="height:25px;width:164px">
                            <option value="1">大一</option>
                            <option value="2">大二</option>
                            <option value="3">大三</option>
                            <option value="4">大四</option>
                        </select>
                        <input type="button" class="button" id="btn0" value="查询" v-on:click="getTable()"/>
                        <div id="dv0" style="display:none">
                            <HR>
                            <table id="cao" class="Table">
                                <tr align="center">
                                    <th>时间段</th><th>节次</th><th>星期一</th><th>星期二</th><th>星期三</th><th>星期四</th><th>星期五</th><th>星期六</th><th>星期日</th>
                                </tr>
                            </table>
                        </div>

                </fieldset>
                <br>
            </div>
            <!--下面是课程安排-->
            <div>
                <input type="button" class="button" style="float: right;width: 70px;margin-right: 15px;margin-top: 15px" value="删除课程" v-on:click="op()">
                <input type="button" class="button" style="float: right;width: 70px;margin-top: 15px" value="添加课程" v-on:click="open()">
                <dialog class="Dialog0" id="dialog0" >
                    <div style="border: 2px seashell">
                        <h3 class="h">添加课程</h3><hr>
                        <div class="insertdiv"><li class="li_style0">学 年 : </li><select class="insert" style="height:25px;width:164px" id = "insert_year" v-model="insert_year">
                            <option value="2019-2020学年">2019-2020学年</option>
                            <option value="2018-2019学年">2018-2019学年</option>
                            <option value="2017-2018学年">2017-2018学年</option>
                            <option value="2016-2017学年">2016-2017学年</option>
                            <option value="2015-2016学年">2015-2016学年</option>
                            <option value="2014-2015学年">2014-2015学年</option>
                        </select></div>
                        <div class="insertdiv"><li class="li_style0">学 期 : </li><select class="insert"style="height:25px;width:164px" id = "insert_semester" v-model="insert_semester">
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                        </select></div>
                        <div class="insertdiv"><li class="li_style0">年 级 ：</li><select class="insert"style="height:25px;width:164px" id = "insert_grade" v-model="insert_grade">
                            <option value="1">大一</option>
                            <option value="2">大二</option>
                            <option value="3">大三</option>
                            <option value="4">大四</option>
                        </select></div>
                        <div class="insertdiv"><li class="li_style0">专 业 : </li><input class="insert"style="height:25px;width:164px" id="insert_majorName"name="专业" type="text" v-model="insert_majorName" />
                        </div>
                        <div class="insertdiv"><li class="li_style0">课程号 : </li><input class="insert"style="height:25px;width:164px" id="insert_cno"name="课程号" type="text" v-model="insert_cno"/>
                        </div>
                        <div class="insertdiv"><li class="li_style0">课程名 : </li><input class="insert"style="height:25px;width:164px" id="insert_cName"name="课程名" type="text" v-model="insert_cName"/>
                        </div>
                        <div class="insertdiv"><li class="li_style0">开课学院: </li><input class="insert"style="height:25px;width:164px" id="insert_college"name="开课学院" type="text" v-model="insert_college"/>
                        </div>
                        <div class="insertdiv"><li class="li_style0">课程描述: </li><input class="insert"style="height:25px;width:164px" id="insert_description"name="课程描述" type="text"  v-model="insert_description"/>
                        </div>
                        <div class="insertdiv"><li class="li_style0">容 量 : </li><input class="insert"style="height:25px;width:164px" id="insert_capacity"name="容量" type="text" v-model="insert_capacity"/>
                        </div>
                    </div><hr>
                    <div style="height: 25px">
                        <input type="button" class="button" name="确认" style="margin-left: 75%;" value="添加" v-on:click="add()">
                        <input type="button" class="button" name="取消" style="float: right;margin-top: 5px"  value="取消" v-on:click="esc()">
                    </div>
                </dialog>
                <dialog class="Dialog1" id="dialog1">
                    <h3 class="h">删除课程</h3><hr>
                    <div class="insertdiv">
                        <li class="li_style0">课程的编号: </li><input  style="height:25px;width:164px" type="text" id="deleteCno" v-model="deleteCno" name="课程编号">
                    </div>
                    <div class="insertdiv">
                        <li class="li_style0">开课学年: </li><select  style="height:25px;width:164px" id = "deleteYear" v-model="deleteYear" name="开课学年">
                        <option value="2019-2020学年">2019-2020学年</option>
                        <option value="2018-2019学年">2018-2019学年</option>
                        <option value="2017-2018学年">2017-2018学年</option>
                        <option value="2016-2017学年">2016-2017学年</option>
                        <option value="2015-2016学年">2015-2016学年</option>
                        <option value="2014-2015学年">2014-2015学年</option>
                    </select>
                    </div>
                    <div class="insertdiv">
                        <li class="li_style0">开课学期: </li><select  style="height:25px;width:164px" type="text" id="deleteSemester" v-model="deleteSemester" name="开课学年">
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                    </select>
                    </div>
                    <div class="insertdiv">
                        <li class="li_style0">专业: </li><input style="height:25px;width:164px" type="text" id="deleteMajorName" v-model="deleteMajorName" name="专业">
                    </div>
                    <div class="insertdiv">
                        <li class="li_style0">年级: </li><select style="height:25px;width:164px" id = "deleteGrade" v-model="deleteGrade" name="年级">
                        <option value="1">大一</option>
                        <option value="2">大二</option>
                        <option value="3">大三</option>
                        <option value="4">大四</option>
                    </select>
                    </div>
                    <div style="height: 25px">
                        <input type="button" class="button" id="Del" style="width: 75px" value="确认删除" v-on:click="deletecourse()">
                        <input type="button" class="button" name="取消删除" style="width: 75px ;float: right;margin-top: 5px"  value="取消删除" v-on:click="esc()">
                    </div>
                    </dialog>
                <div class="course_mag">
                    <fieldset><legend><h2>课程安排</h2></legend>
                        <h5>学年：</h5><select id = 'change_year' v-model="input_year" style="height:25px;width:164px">
                            <option value="2019-2020学年">2019-2020学年</option>
                            <option value="2018-2019学年">2018-2019学年</option>
                            <option value="2017-2018学年">2017-2018学年</option>
                            <option value="2016-2017学年">2016-2017学年</option>
                            <option value="2015-2016学年">2015-2016学年</option>
                            <option value="2014-2015学年">2014-2015学年</option>
                        </select>
                        <h5>学期：</h5><select id = 'change_semester' v-model="input_semester" style="height:25px;width:164px">
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                        </select>
                        <h5>专业：</h5><input id="change_majorName" v-model="input_majorName" name="专业" type="text" />
                        <h5>年级：</h5><select id = 'change_grade' v-model="input_grade" style="height:25px;width:164px">
                            <option value="1">大一</option>
                            <option value="2">大二</option>
                            <option value="3">大三</option>
                            <option value="4">大四</option>
                        </select>
                        <button type="button" class="button" id="btn1"  v-on:click="search()">查询</button>
                        <div id="dv1" style="display:none">
                            <HR>
                            <table class="Table">
                                <thead style="text-align: center;border: 2px solid #171a1d;">
                                <tr>
                                    <th>课程号</th>
                                    <th>课程名</th>
                                    <th>开课学院</th>
                                    <th>课程描述</th>
                                    <th>是否已开</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr v-for="course in allWillCourses">
                                    <td>{{course.cno}}</td>
                                    <td>{{course.cname}}</td>
                                    <td>{{course.college}}</td>
                                    <td>{{course.description}}</td>
                                    <td>{{course.ifOpen}}</td>
                                    <td>
                                        <input type="button" class="button1" value="课程安排" v-on:click="eachCourse(course)">
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </fieldset>
                    <br>
                </div>
            </div>
            <dialog class="Dialog" id="Dialog">
                    <h3 class="h">课程安排</h3>
                    <li class="li_style">教师安排</li>
                        <h5>教师: </h5>
                        <input type="button" id="teacherName" class="BBT" value="未安排" />
                    <div id="div0">
                        <input type="search"  class="header_search" id="oneTeacher" placeholder="输入教师工号或名字"/>
                        <input type="button" class="button0" id="btn3"  value="查询"  v-on:click="searchTeacher()">
                         <br>
                         <div id ="div01" style="display:none">
                            <table class="Table" >
                                <thead>
                                <tr>
                                    <td align="center" valign="middle">工号</td>
                                    <td align="center" valign="middle">名字</td>
                                    <td align="center" valign="middle">性别</td>
                                    <td align="center" valign="middle">操作</td>
                                </tr>
                                </thead>
                                <tbody>
                                <!--放后台查询数据返回的结果-->
                                <tr v-for="teacher in allTeachers">
                                    <td>{{teacher.tno}}</td>
                                    <td>{{teacher.tname}}</td>
                                    <td>{{teacher.sex}}</td>
                                    <td>
                                        <input type="button" class="button1" id="oneTeacherButton" value="课程安排" v-on:click="eachTeacher(teacher)">
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div><hr>
                    <li class="li_style">教室安排</li>
                    <h5>教室: </h5>
                    <input type="button" id="classroomName" class="BBT" value="未安排" />
                    <div id="div1">
                        <input type="search" class="header_search" id="classRoom" placeholder="输入教室编号"/>
                        <input type="button" class="button0" id="btn4"  value="确定" v-on:click="classRoom()">
                    </div><br>
                    <div id="div2"><hr>
                        <li class="li_style">时间安排</li>
                        <div style="text-align: right">
                            <input type="button" class="button" style="width: 110px" id="btn5" value="添加其它时间段" v-on:click="addTime()" >
                        </div>
                        <div id="allTime0">
                            <form  method="get">
                                <label><h5>周数:</h5>
                                    <select name="time_start" class="select_style" onchange="sel()">
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                        <option value="5">5</option>
                                        <option value="6">6</option>
                                        <option value="7">7</option>
                                        <option value="8">8</option>
                                        <option value="9">9</option>
                                        <option value="10">10</option>
                                        <option value="11">11</option>
                                        <option value="12">12</option>
                                        <option value="13">13</option>
                                        <option value="14">14</option>
                                        <option value="15">15</option>
                                        <option value="16">16</option>
                                        <option value="17">17</option>
                                        <option value="18">18</option>
                                        <option value="19">19</option>
                                        <option value="20">20</option>
                                    </select>
                                </label>
                                <label><h5>至</h5>
                                    <select  name="time_end" class="select_style">
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                        <option value="5">5</option>
                                        <option value="6">6</option>
                                        <option value="7">7</option>
                                        <option value="8">8</option>
                                        <option value="9">9</option>
                                        <option value="10">10</option>
                                        <option value="11">11</option>
                                        <option value="12">12</option>
                                        <option value="13">13</option>
                                        <option value="14">14</option>
                                        <option value="15">15</option>
                                        <option value="16">16</option>
                                        <option value="17">17</option>
                                        <option value="18">18</option>
                                        <option value="19">19</option>
                                        <option value="20">20</option>
                                    </select>
                                </label>
                                <label><h5>星期:</h5>
                                    <select name="week" class="select_style">
                                        <option value="1">星期一</option>
                                        <option value="2">星期二</option>
                                        <option value="3">星期三</option>
                                        <option value="4">星期四</option>
                                        <option value="5">星期五</option>
                                        <option value="6">星期六</option>
                                        <option value="7">星期日</option>
                                    </select>
                                </label>
                                <label><h5>节数:</h5>
                                    <select name="section1" class="select_style">
                                        <option value="1">第一节</option>
                                        <option value="2">第二节</option>
                                        <option value="3">第三节</option>
                                        <option value="4">第四节</option>
                                        <option value="5">第五节</option>
                                        <option value="6">第六节</option>
                                        <option value="7">第七节</option>
                                        <option value="8">第八节</option>
                                        <option value="9">第九节</option>
                                        <option value="10">第十节</option>
                                        <option value="11">第十一节</option>
                                        <option value="12">第十二节</option>
                                        <option value="13">第十三节</option>
                                    </select>
                                </label>
                                <label><h5>至</h5>
                                    <select  name="section2" class="select_style">
                                        <option value="1">第一节</option>
                                        <option value="2">第二节</option>
                                        <option value="3">第三节</option>
                                        <option value="4">第四节</option>
                                        <option value="5">第五节</option>
                                        <option value="6">第六节</option>
                                        <option value="7">第七节</option>
                                        <option value="8">第八节</option>
                                        <option value="9">第九节</option>
                                        <option value="10">第十节</option>
                                        <option value="11">第十一节</option>
                                        <option value="12">第十二节</option>
                                        <option value="13">第十三节</option>
                                    </select>
                                </label>
                                </form>
                        </div>
                    </div>
                    <hr><br>
                    <div id="div5" align="right" style=" padding-left:100px">
                        <input class="button" type="button" value="确认" v-on:click="addAll()"/>
                        <a style="padding-right:100px"></a>
                        <input class="button" type="button" value="取消" v-on:click="deleteCourse()"/>
                    </div>
                </dialog>

        </main>

    </div>
</div>

<script type="text/javascript" th:inline="javascript" >
    var app = new Vue({
        el:'#classscheduling',

        data:{
            array:[],
            i:1,
            sum:1,
            allWillCourses:[],
            allTeachers:[],
            getWillCourses:"",
            input_year:"",
            input_semester:"",
            input_majorName:"",
            input_grade:"",
            input_tno:"",
            input_tname:"",
            nowCourseCno:"",
            nowCourseTno:"",
            nowCourseYear:"",
            nowCourseSemester:"",
            nowCourseMajorName:"",
            nowCourseGrade:"",
            nowCourseStatus:"",
            nowCourseCapacity:"",
            nowCourseAddress:"",
            nowCourseTime:"",
            table_year:"",
            table_semester:"",
            table_major:"",
            table_grade:"",
            allCourses:[],
            insert_year:"",
            insert_semester:"",
            insert_grade:"",
            insert_majorName:"",
            insert_cno:"",
            insert_cName:"",
            insert_description:"",
            insert_college:"",
            insert_capacity:"",
            deleteCno:"",
            deleteYear:"",
            deleteSemester:"",
            deleteMajorName:"",
            deleteGrade:"",
        },
        methods:{

            open:function(){
             dialog0.showModal();
            },
            op:function(){
                dialog1.showModal();
            },
            esc:function(){
                dialog0.close();
                dialog1.close();
            },
            deletecourse:function(){
                this.$http.post("/deleteCourse",{
                        cno:this.deleteCno,
                        year:this.deleteYear.substring(0,4),
                        semester:this.deleteSemester,
                        majorName:this.deleteMajorName,
                        grade:this.deleteGrade
                    },
                    {emulateJSON:true}).then(function (value) {
                    },
                    function (reason) {
                    }
                );
                this.$http.post("/deleteWillCourse",{
                    cno:this.deleteCno,
                    year:this.deleteYear.substring(0,4),
                    semester:this.deleteSemester,
                    majorName:this.deleteMajorName,
                    grade:this.deleteGrade
                },
                {emulateJSON:true}).then(function (value) {

                        alert("删除成功！")
                        dialog1.close();
                    },
                function (reason) {
                    alert("请求出错！")
                }
                );
            },
            add:function(){
                this.$http.post("/addWillCourse", {
                        cno:this.insert_cno,
                        cname:this.insert_cName,
                        college:this.insert_college,
                        description:this.insert_description,
                        status:"true",
                        year:this.insert_year.substring(0,4),
                        semester:this.insert_semester,
                        majorName:this.insert_majorName,
                        grade:this.insert_grade,
                    },
                    {emulateJSON:true}).then(function (value) {
                        console.log("addWillCourse Success")
                        alert("添加成功")
                         dialog0.close();
                        //console.log(this.deleteCourse);

                    },
                    function (reason) {
                        alert("请求出错")
                    }
                );
            },
            deleteCourse:function(){
                this.$http.post("/deleteCourse", {
                        cno:this.nowCourseCno,
                        year:this.nowCourseYear,
                        semester:this.nowCourseSemester,
                        majorName:this.nowCourseMajorName,
                        grade:this.nowCourseGrade
                    },
                    {emulateJSON:true}).then(function (value) {
                        //console.log("222")
                        this.deleteCourse=value.body.data;
                        //console.log(this.deleteCourse);
                        /*开始操作*/
                        alert("取消成功")
                        Dialog.close();
                        this.search()
                    },
                    function (reason) {
                        alert("请求出错")
                    }
                );
            }
            ,
            init_array:function(){
                var table = document.getElementById('cao');
                table.border = 1;
                table.style.tableLayout = 'fixed';
                table.style.wordBreak = 'break-all';
                table.style.wordWrap = 'break-word';
                table.style.textAlign = 'center';
                if(table.rows.length>1){
                    for(var x=table.rows.length-1;x>=1;x--){
                        table.deleteRow(x);
                    }
                }
                this.array = [];
                for(var i=0;i<13+1;i++){
                    var temp = [];
                    for(var j = 0;j<9+1;j++){
                        temp.push([-1,-1,-1]);
                    }
                    this.array.push(temp);
                }
                for(var i=1;i<=5;i++){
                    this.array[i][1] = [1,5,"上午"];
                }
                for(var i=6;i<=10;i++){
                    this.array[i][1] = [6,10,"下午"];
                }
                for(var i=11;i<=13;i++){
                    this.array[i][1] = [11,13,"晚上"];
                }
                for(var i=1;i<=13;i++){
                    this.array[i][2] = [i,i,i];
                }
            },
            insert_one_lesson:function(course){
                var string = "";
                string = string + course.name+'\n';
                string = string + "("+course.start+'-'+course.end+'节)/'+course.long+'周/'+course.address+'/'+course.teacher;
                //console.log("++++")
                //console.log(course.start)
                //console.log(course.end)
                for(var i=parseInt(course.start);i<=parseInt(course.end);i++){
                    this.array[i][parseInt(course.day) + 2] = [course.start,course.end,string];
                } 
            },
            insert_course:function(all_course){
                //console.log("-------------------------------");
                //console.log(all_course)
                var temp_array = all_course.course_time.split(';');
                var course = {address:all_course.address,
                    name:all_course.cname,
                    teacher:all_course.tname,
                    start:null, end:null, day:null, long:null};
                for(var x in temp_array) {
                    //console.log(x);
                    var temp = temp_array[x].split(',');
                    temp[0] = temp[0].substring(1, temp[0].length);
                    temp[2] = temp[2].substring(0, temp[2].length - 1);
                    course.long = temp[0];
                    course.day = temp[1];
                    var temp1 = temp[2].split('-');
                    course.start = temp1[0];
                    course.end = temp1[1];
                    //console.log(course);
                    this.insert_one_lesson(course);
                }
            },
            create_table:function(){
                var table = document.getElementById('cao');
                for(var i=1;i<=13;i++){
                    var row = table.insertRow(i);
                    var len = 0;
                    for(var j=1;j<=9;j++){
                        if(this.array[i][j][0]==-1){
                            var cell=row.insertCell(len);
                            cell.width = 100;
                            cell.height = 35;
                            len = len + 1;
                        }else{
                            if(this.array[i][j][0] == i){
                                var cell=row.insertCell(len);
                                cell.width = 100;
                                cell.height = 35;
                                cell.rowSpan = parseInt(this.array[i][j][1]) - parseInt(this.array[i][j][0]) + parseInt(1);
                                //console.log(cell.rowSpan);
                                len = len + 1;
                                cell.innerHTML = this.array[i][j][2];
                            }
                        }

                    }
                }
            },
            getTable:function () {
                //console.log("hello")
                this.$http.post("/getAllCourses", {
                        year:this.table_year.substring(0,4),
                        semester:this.table_semester,
                        major:this.table_major,
                        grade:this.table_grade
                    },
                    {emulateJSON:true}).then(function (value) {
                        //console.log("222")
                        this.allCourses=value.body.data;
                        //console.log(this.allCourses);
                        /*开始操作*/
                        this.init_array();
                        for(var i=0;i<this.allCourses.length;i++){
                            this.insert_course(this.allCourses[i]);
                        }
                        this.create_table();
                        //console.log(this.array);
                        dv0.style.display="block";
                    },
                    function (reason) {
                        alert("请求出错")
                    }
                );
            },
            search:function() {
                year = this.input_year.substring(0,4);
                //console.log(this.input_year)
                //console.log(this.input_semester)
                //console.log(this.input_majorName)
                //console.log(this.input_grade)
                dv1.style.display="block";
                this.$http.post("/getWillCourses", {
                        year:this.input_year.substring(0,4),
                        semester:this.input_semester,
                        majorName:this.input_majorName,
                        grade:this.input_grade
                    },
                    {emulateJSON:true}).then(function (value) {
                        //console.log("222");
                        this.allWillCourses=value.body.data;
                    },
                    function (reason) {
                        alert("请求出错")
                    }
                );
            },
            eachCourse:function (course) {
                this.allTeachers = [];
                this.nowCourseYear = this.input_year.substring(0, 4);
                this.nowCourseSemester = this.input_semester;
                this.nowCourseMajorName = this.input_majorName;
                this.nowCourseGrade = this.input_grade;
                this.nowCourseCno = course.cno;
                //console.log("1111");
                Dialog.showModal();
            },
            eachTeacher:function(teacher) {
                teacherName.valueOf().value=teacher.tname;
                oneTeacherButton.disable=false;
                this.nowCourseTno = teacher.tno;
                document.getElementById("oneTeacherButton").value="已添加";
                alert("已添加");
            },
            classRoom:function(){
                this.nowCourseAddress = document.getElementById("classRoom").valueOf().value;
                if(document.getElementById("classRoom").valueOf().value=="null")
                {
                    alert("请输入正确的教室编号！")
                }
                else{
                    classroomName.valueOf().value=this.nowCourseAddress;
                    alert("已添加")
                }
            },
            addTime:function(){
                var sourceNode = document.getElementById("allTime0");
                var clonedNode = sourceNode.cloneNode(true);
                clonedNode.setAttribute("id", "allTime" + this.i);
                sourceNode.parentNode.appendChild(clonedNode);
                this.i=this.i+1;
                this.sum = this.sum + 1;
            },
            addAll:function(){
                /*这里需要生成时间字符串*/
                //console.log(this.sum)
                var array = "";
                for (var id = 0;id<this.sum;id++){
                    if(id != 0){array = array + ";"}
                    var string = "(";
                    //console.log(document.getElementsByName("time_start")[id].value);
                    string = string + document.getElementsByName("time_start")[id].value;
                    string = string + "-" + document.getElementsByName("time_end")[id].value+",";
                    string = string + document.getElementsByName("week")[id].value + ",";
                    string = string + document.getElementsByName("section1")[id].value;
                    string = string + "-" + document.getElementsByName("section2")[id].value + ")";
                    array = array + string;
                }
                //console.log(array)
                this.nowCourseTime = array;
                /*这里需要发送请求*/
                //console.log(this.input_grade);
                this.$http.post("/addCourse", {
                        cno:this.nowCourseCno,
                        tno:this.nowCourseTno,
                        year:this.nowCourseYear,
                        semester:this.nowCourseSemester,
                        majorName:this.nowCourseMajorName,
                        grade:this.nowCourseGrade,
                        status:1,
                        capacity:150,
                        address:this.nowCourseAddress,
                        time:this.nowCourseTime
                    },
                    {emulateJSON:true}).then(function (value) {
                        //console.log("222");
                        //console.log(value);
                        if(value) alert("添加成功")
                        Dialog.close();
                        this.search();
                    },
                    function (reason) {
                        alert("请求出错")
                    }
                );
            },
            searchTeacher:function(){
                div01.style.display="block";
                this.allTeachers = [];
                var temp = document.getElementById("oneTeacher").valueOf().value
                var flag = 1;
                for(var x in temp){
                    if(temp[x]<"0" || temp[x] >"9"){
                        flag = 2;
                    }
                }
                if(flag==1){this.input_tname="";this.input_tno=temp;}
                else{this.input_tno="";this.input_tname=temp;}
                if(this.input_tno == ""){this.input_tno=-1;}
                if(this.input_tname == ""){this.input_tname="null";}
                this.$http.post("/getTeacherByTnoAndTname", {
                        tno:this.input_tno,
                        tname:this.input_tname
                    },
                    {emulateJSON:true}).then(function (value) {
                        //console.log("222");
                        this.allTeachers=value.body.data;
                    },
                    function (reason) {
                        alert("请求出错")
                    }
                );
            }
        }
    });
</script>

<!-- Bootstrap core JavaScript
=============================xQ===================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
        crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
        crossorigin="anonymous"></script>

<!-- Icons -->
<script src="https://unpkg.com/feather-icons/dist/feather.min.js"></script>
<script>
    feather.replace()
</script>

<!-- Graphs -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>

</body>
</html>